import { Injectable } from '@angular/core';

import { ModalOptions, NzModalRef, NzModalService } from 'ng-zorro-antd/modal';

import { SingleInputModalComponent } from './single-input-modal.component';

const defaultOptions = {
  nzTitle: '',
  nzClosable: false,
  nzMaskClosable: false
};

@Injectable()
export class SingleInputModalService {
  constructor(private modalSrc: NzModalService) {}
  public open(title: string, params?: any, options?: ModalOptions): NzModalRef {
    const newOptions = { ...defaultOptions, ...options };
    if (params) {
      newOptions.nzComponentParams = params;
    }
    newOptions.nzContent = SingleInputModalComponent;
    newOptions.nzTitle = title;
    newOptions.nzFooter = null;
    return this.modalSrc.create(newOptions);
  }
}
